package com.rocching.easychat.core;

import android.text.SpannableString;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.rocching.easychat.EasyChatApp;
import com.rocching.easychat.R;

import java.util.List;

import io.rong.imkit.conversationlist.ConversationListAdapter;
import io.rong.imkit.conversationlist.model.BaseUiConversation;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.MessageContent;
import io.rong.message.ContactNotificationMessage;

public class ConversationListAdapterEx extends ConversationListAdapter {
    @Override
    public void setDataCollection(List<BaseUiConversation> data) {
        if (data != null) {
            for (BaseUiConversation baseUiConversation : data) {
                Conversation conversation = baseUiConversation.mCore;
                MessageContent messageContent = conversation.getLatestMessage();
                if (messageContent instanceof ContactNotificationMessage) {
                    ContactNotificationMessage content = (ContactNotificationMessage) messageContent;

                    baseUiConversation.mConversationContent = new SpannableString(content.getMessage());
                    //conversation.setConversationTitle(EasyChatApp.getContext().getString(R.string.msg_friend_tip));
                }
            }
        }
        super.setDataCollection(data);
    }
}
